package com.zhj.controller;

import com.zhj.po.CmsSubject;
import com.zhj.service.DemoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class BizpageController {

    private static Logger logger=LoggerFactory.getLogger("apiLog");

    @Autowired
    private DemoService demoService;

    // 登录
   /* @PostMapping("/login")
    @ResponseBody
    public String index(String username,String password) {
        return "index";
    }*/

    // 登录成功之后的首页

    @GetMapping("/index1")
    public String index() {
        return "index";
    }

    // 日志管理
    @GetMapping("/sys_log1")
    public String showOrder() {
        CmsSubject cmsSubject = demoService.selectOneById(1);
        System.out.println(cmsSubject);
        return "syslog";
    }

    // 用户管理
    @GetMapping("/sys_user1")

    public String addOrder(String test) {
        logger.info("当前用户访问了sys_user1页面");
        demoService.select(1);

        return "sysuser";
    }

    // 具体业务一
    @GetMapping("/biz1")
    public String updateOrder() {
        CmsSubject cmsSubject = demoService.selectOneById(1);
        System.out.println(cmsSubject);
        return "biz1";
    }

    // 具体业务二
    @GetMapping("/biz2")
    public String deleteOrder() {
        return "biz2";
    }
   /* //登出
    @GetMapping({"/logout"})
    public String logout(HttpServletRequest request, HttpServletResponse response) {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if (auth != null) {//清除认证
            new SecurityContextLogoutHandler().logout(request, response, auth);
        }

        return "login";

    }*/

}